package com.wy.powerbuilder.service.impl.ld;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wy.powerbuilder.entity.ld.Role;
import com.wy.powerbuilder.entity.ld.User;
import com.wy.powerbuilder.mapper.ld.RoleMapper;
import com.wy.powerbuilder.service.ld.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class RoleServiceimpl implements RoleService {
    @Autowired
    private RoleMapper roleMapper;
    @Override
    public List<Role> all() {
        List<Role> roles=roleMapper.all();
        return roles;
    }

    @Override
    public PageInfo<Role> pageAll(Integer pageNo) {
        if(pageNo==null){
            pageNo=1;
        }
        PageHelper.startPage(pageNo,6);
        List<Role> roles=roleMapper.showAll();
        System.out.println(roles.size());
        PageInfo<Role> pageInfo=new PageInfo<>(roles);
        return pageInfo;
    }

    @Override
    public Integer addRole(Role role) {
        return roleMapper.addRole(role);
    }

    @Override
    public Role getRole(String r_name) {
        return roleMapper.getRole(r_name);
    }

    @Override
    public Integer delRole(int id) {
        return roleMapper.delRole(id);
    }

    @Override
    public Role showRole(Integer id) {
        return roleMapper.showRole(id);
    }

    @Override
    public int updateRole(Role role) {
        return roleMapper.updateRole(role);
    }

}
